package com.lecing.utils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * excel 模板定义封装
 * Created by liucs on 2018/5/30.
 */
public class ExcelTpl {
    public  enum TplType {
        LEDGER,  //月总账

        M_PAY_LOAN,     //月付放款
        Y_PAY_LOAN,     //年付放款
        M_LOAN_DAY_VOU,     //月付放款凭证
        Y_LOAN_DAY_VOU,     //年付放款凭证

        M_PAY_REPAY,    //月付还款月明细
        Y_PAY_REPAY,    //年付还款月明细

        M_PAY_REFUND,   //月付违约返（退）款模板
        PAY_REFUND,     //月付/年付违约返款模板

        FLAT_TOPUP,     //公寓充值
        FLAT_WITHDRAW,  //公寓提现

        FUNDS_PLAN,     //资金计划
        FUNDS_PLAN_DETAIL   //资金计划明细

    }

    /**
     * 获取对应的TPL模板文件
     * @param tplType
     * @return
     */
    public static String getTplPath(TplType tplType){
        String tplPath ="";
        String tplFile="";
        switch (tplType){
            case LEDGER:
                tplFile="./template/loanOutTpl.xlsx";
                break;
            case M_PAY_LOAN:
                tplFile="./template/月付放款.xlsx";
                break;
            case Y_PAY_LOAN:
                tplFile="./template/年付放款.xlsx";
                break;
            case M_LOAN_DAY_VOU:
                tplFile="./template/月付日放款凭证.xlsx";
                break;
            case Y_LOAN_DAY_VOU:
                tplFile="./template/年付日放款凭证.xlsx";
                break;
            case M_PAY_REPAY:
                tplFile="./template/月付还款.xlsx";
                break;
            case Y_PAY_REPAY:
                tplFile="./template/年付还款.xlsx";
                break;
        }
        tplPath = ExcelTpl.class.getClassLoader().getResource(tplFile).getPath();
        return  tplPath;
    }
    /**
    public static void main(String[] args) throws UnsupportedEncodingException {
        String tplFile=getTplPath(TplType.M_LOAN_DAY_VOU);
        String utf8Path=URLEncoder.encode(tplFile,"UTF-8");
        System.out.println(tplFile);
    }
     */
}
